{% extends "base.html" %}
{% block content %}
<h1>{{ greeting }} {{ name }} !</h1>
<p>
  <a href="/hello/{{ name }}">Greeting page</a> shows how named
  arguments given in URLs are naturally inserted into Context. You may
  try with <a href="/hello/Burich/">Burich</a>, <a
  href="/hello/Umbre/">Umbre</a> or <a
  href="/hello/Fitz/">Fitz</a></p>
<p>
  Go to <a href="/bye/{{ name }}">Farewell page</a> to see same
  mechanism in action with (again) an instance variable overriding the
  class value. Again, you may try with <a
  href="/bye/Burich/">Burich</a>, <a href="/bye/Umbre/">Umbre</a> or
  <a href="/bye/Fitz/">Fitz</a>
</p>
<div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">obviews.views</span> <span class="kn">import</span> <span class="n">View</span><span class="p">,</span> <span class="n">FormView</span>

<span class="c"># Adding a dynamic variables in context, in *calls*</span>
<span class="k">class</span> <span class="nc">DynamicView</span><span class="p">(</span><span class="n">View</span><span class="p">):</span>
    <span class="n">template_name</span> <span class="o">=</span> <span class="s">&quot;greet.html&quot;</span>
    <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span><span class="s">&quot;greeting&quot;</span><span class="p">:</span> <span class="s">&quot;Hello&quot;</span><span class="p">}</span>

<span class="n">urlpatterns</span> <span class="o">=</span> <span class="n">patterns</span><span class="p">(</span><span class="s">&#39;&#39;</span><span class="p">,</span>
    <span class="p">(</span><span class="s">&#39;^hello/(?P&lt;name&gt;\w+)/$&#39;</span><span class="p">,</span> <span class="n">DynamicView</span><span class="p">()),</span>
    <span class="p">(</span><span class="s">&#39;^bye/(?P&lt;name&gt;\w+)/$&#39;</span><span class="p">,</span> <span class="n">DynamicView</span><span class="p">(</span><span class="n">greeting</span><span class="o">=</span><span class="s">&quot;Bye&quot;</span><span class="p">)),</span>
<span class="p">)</span>

</pre></div>
<p>
  Note in this example that the second param defined in URL appears in
  the signature of build_param. This view will inheritate all static
  vars defined in mother class (and its template also if not
  overwriten. In the <strong>next example</strong>, we will see how
  the <a href="/private/">decorator <code>@login_required</code></a>
  is integrated into the object...
</p>
{% endblock %}
